package com.nondo.rdp.finance.service.impl.setting.home;

import com.nondo.rdp.finance.domain.setting.home.SettingModule;
import com.nondo.rdp.finance.domain.setting.home.SettingModuleCustomer;
import com.nondo.rdp.finance.repository.setting.home.SettingModuleCustomerRepository;
import com.nondo.rdp.finance.service.setting.home.SettingModuleCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class SettingModuleCustomerServiceImpl implements SettingModuleCustomerService {
    @Autowired
    SettingModuleCustomerRepository settingModuleCustomerRepository;

    @Override
    public SettingModuleCustomer findOne(Long id) {
        return this.settingModuleCustomerRepository.findOne(id);
    }

    @Override
    public SettingModuleCustomer save(SettingModuleCustomer settingModuleCustomer) {
        return this.settingModuleCustomerRepository.save(settingModuleCustomer);
    }

    @Override
    public void update(SettingModuleCustomer settingModuleCustomer) {
        this.settingModuleCustomerRepository.save(settingModuleCustomer);
    }

    @Override
    public void delete(Long id) {
        this.settingModuleCustomerRepository.deleteById(id);
    }

    @Override
    public List<SettingModuleCustomer> findAll(SettingModule module, Sort sort) {
        return this.settingModuleCustomerRepository.findAllByModuleAndDelFlag(module, "0", sort);
    }
}